package com.xlp.snake.entities;

import java.awt.Graphics;
import java.awt.Point;

import javax.swing.ImageIcon;

import com.xlp.snake.util.Global;

public class Food extends Point {
	
    //添加食物
	public void newFood(Point p) {
		if(Snake.life = true ) {
		this.setLocation(p);
	  }
	}
	
	//蛇是否吃到食物的方法
	public boolean isSnakeEatFood(Snake snake) {
		System.out.println("Food's isSnakeEatFood");

		return this.equals(snake.getHead());

	}

	//显示
	public void drawMe(Graphics g) {
		System.out.println("Food's drawMe");

		g.fill3DRect(x * Global.CELL_SIZE, y * Global.CELL_SIZE, Global.CELL_SIZE, Global.CELL_SIZE, true);
	}
}
